package com.tomvian.screens.transitions 
{
	import flash.utils.setTimeout;
	import com.tomvian.screens.AbstractScreen;
	import com.tomvian.screens.AbstractTransition;
	
	/**
	 * Delay
	 * @author Tom Vian
	 */
	public class Delay extends AbstractTransition
	{
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		protected var _delayOut:uint;
		protected var _delayIn:uint;
		
		//--------------------------------------------------------------------------
		//
		//  Getters / Setters
		//
		//--------------------------------------------------------------------------
		
		//--------------------------------------------------------------------------
		//
		//  Constructor
		//
		//--------------------------------------------------------------------------
		
		public function Delay(delayOut:uint = 0, delayIn:uint = 0) 
		{
			_delayOut = delayOut;
			_delayIn = delayIn;
		}
		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		override public function play(fromScreen:AbstractScreen, toScreen:AbstractScreen):void 
		{
			super.play(fromScreen, toScreen);
			
			setTimeout(swap, _delayOut);
			setTimeout(onTransitionComplete, _delayOut + _delayIn + 1);
		}
	}
}